/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/userdata/UDCLicenseHandler.h,v 1.6 2003/11/21 12:39:24 itsme Exp $
 *
 *
 */


#ifndef __LICENSEHANDLER_H__

#include "UserDataHandler.h"

typedef struct _tagLicenseHashMessage {
    BYTE msg;
    BYTE hash[32];
} LicenseHashMessage;

class CCPhoneDlg;

class UDCLicenseHandler : public UDClientHandler {
public:
    UDCLicenseHandler(CCPhoneDlg& dlg);
    ~UDCLicenseHandler();

    bool HandleUserdataMessage(const ByteVector& data);
    bool SendLicenseHashMessage(const ByteVector& hash);
    virtual bool StopSending();

    bool VerifyROMLicense(const std::string& imei);

    ByteVector GetChecksum();
    ByteVector GetLicense();

private:
        CCPhoneDlg& m_dlg;
        ByteVector m_signaturehash;

        ByteVector m_licensesignature;
        ByteVector m_licensedata;
        ByteVector m_licensepublickey;

    bool ReadROMData();

    bool HandleLicenseHashMessage(const ByteVector& hash);

    void VerifyLicense(const ByteVector& hash);

    bool GetLicenseHash(ByteVector& licensehash);

    bool IsKnownKey(const ByteVector& key);

    void DoLicenseViolation();
};


#define __LICENSEHANDLER_H__
#endif
